/*
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
*/
package cmd

import (
	"fmt"
	"log"
	"os"

	"gitee.com/liaojin0910/jtools"
	"github.com/spf13/cobra"
)

// g2mdCmd represents the g2md command
var g2mdCmd = &cobra.Command{
	Use:   "g2md",
	Short: "将特定格式的go test文件，转换为 markdown 文件",
	Long: `
		jin g2md xx_test.go
	`,
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) < 1 {
			log.Fatalln("参数不对")
		}

		f, err := os.Open(args[0])
		if err != nil {
			log.Fatalln("参数文件错误")
		}
		markdown := jtools.G2md(f)
		fmt.Println(markdown)
	},
}

func init() {
	rootCmd.AddCommand(g2mdCmd)
}
